package main.module.castle
{
	import com.standlibrary.global.Global;
	import com.standlibrary.load.GetObject;
	import com.standlibrary.ui.base.BaseSprite;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.geom.Rectangle;
	
	import main.manager.SenceManger;

	/**
	 * 城堡外观
	 * @author bianbo
	 */
	public class OuterSence extends BaseSprite
	{
		private var mainMC:MovieClip;
		
		public function OuterSence()
		{
			mainMC = GetObject.getMC("Landform");
			mainMC.builder.buttonMode = true;
			mainMC.builder.addEventListener(MouseEvent.CLICK, intoCastle);
			addChild(mainMC);
			
			this.addEventListener(MouseEvent.MOUSE_DOWN, beginDrag);
		}
		
		private function intoCastle(eve:MouseEvent):void
		{
			SenceManger.instance.changeSence();
		}
		
		private function beginDrag(eve:MouseEvent):void
		{
			var w:int = this.width - Global.STAGE_WIDTH;
			var h:int = this.height - Global.STAGE_HEIGHT;
			
			this.startDrag(false, new Rectangle(-w, -h, w, h));
			stage.addEventListener(MouseEvent.MOUSE_UP, dragEnd, false, 0, true);
		}
		
		private function dragEnd(eve:MouseEvent):void
		{
			stopDrag();
			stage.removeEventListener(MouseEvent.MOUSE_UP, dragEnd);
		}
	}
}